*** this file will produce all interim data and analysis from the do files and the raw data

* written for Stata 17; required user-written packages: estout

* !!! set the following to the directory where you have extracted the replication files to: !!!
global path  "C:/Users/hspamann/Dropbox/Spamann-Klerman shared/Results_and_analysis"

**************************************************************************************************************
**************************************************************************************************************

cd "$path"
label define judge 1 "Circuit" 2 "District" 3 "Bankruptcy" 4 "Magistrate", replace
label define forum -1 "W" 1 "S", replace
label define location -1 "K" 1 "N", replace
label define sympathy -1 "N" 1 "S", replace
label save judge forum location sympathy using labels, replace

*** PREPARATION -- don't run this part if you only want to reproduce the analysis results
do do_files/merge_raw_results.do // this creates alldata.dta by pulling together the results from 2017 and 2018 from raw files, including transcribed reasons, and, in as far as possible, cleans judge-type information that is missing or erroneous

/*** DEMOGRAPHICS (section 2.1, table 1)
* requires access to participant data, which we do not have permission to share -- if relevant, we can work with you to obtain permission from the FJC
* if you do have the data, set the following global to the appropriate file path
global attendeefile "C:/Users/hspamann/OneDrive - Harvard University/Documents/Projects/In_progress/Experiment2/seminar_participating_judges/FJC_LS_participant_demographics_2015-2018.dta"
do do_files/demographics.do
*/

*** TABULATION (section 3.1, tables 4 & 5 -- note that order of levels of sympathy and location is opposite here as in paper)
use alldata.dta, clear
table (forum) (a_loc), stat(mean cap) stat(total cap) stat(freq)
collect export analysis_output/table4.docx, replace
table (forum) (sympathy a_loc), stat(mean cap) stat(total cap) stat(freq) totals(sympa)
collect export analysis_output/table5.docx, replace


*** ANALYSIS (tables 6 & 7)
do do_files/regressions_revised.do // SECTION 3.2.1 -- table 6
do do_files/conditional_randomization_tests.do // SECTION 3.2.2 -- ingredients of table 7 (plus many variations)

*** APPENDIX A.10 (table A.10)
do do_files/tabulate_data.do // TABLE A.10 -- in two pieces and only displayed on screen / in the log file

